package com.utils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @author :wn
 * @program : 留言板
 * @descript :
 * @create :2020-12-07 11:15
 */
@WebServlet("/login")
public class LoginAction extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name=req.getParameter("code");
        HttpSession session=req.getSession();
        String securityCode = (String) session.getAttribute("securityCode");
        if(name.equals(securityCode)){
            req.getRequestDispatcher("/success.jsp").forward(req,resp);
        }else{
            req.setAttribute("error","失败");
            req.getRequestDispatcher("/index.jsp").forward(req,resp);
        }
    }
}
